var username=localStorage.getItem("username");
var token=localStorage.getItem("token");
var userid=localStorage.getItem("userid");
$.bsgrid.forcePushPropertyInObject(
		$.fn.bsgrid.defaults.extend.renderPerRowMethods,
		'extend_render_per_row', function(record, rowIndex, trObj, options) {
			if (record != undefined && record != '') {
				trObj.attr('id', record.id);
			}
		});

$(function() {
	gridObj = $.fn.bsgrid.init('g_tabYeh', {
		ajaxType : 'get',
		url : server_url+'/rest/sysInfoList.do?token='+token+'&ran='+Math.random(),
		autoLoad : true,
		pageSizeSelect : true,
		stripeRows : true,
		pageSize : 10,
		displayBlankRows : false,
		isProcessLockScreen : true,
		rowSelectedColor : false,
		showPageToolbar:true
	});
});
function operate(record, rowIndex, colIndex, options) {
    return '<a href="javascript:EditSysInfo(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">编辑</a>';
}
// 数据表格参数查询
function doSearch() {
	searchParames = $('#myform').serialize();
	if ($('#sysName').val()==null||$('#sysName').val() == '') {
		gridObj.search('');
	} else {
		gridObj.search(searchParames);
	}
	console.log(searchParames);
}
//添加
function toSysInfoAdd(){
	var url='toSysInfoAdd.do?ran='+Math.random();
	tl_config.loadToWorkArea(url);
	
}
// 编辑
function EditSysInfo(id) {
	var url='toSysInfoUpd.do?id='+id+'&ran='+Math.random();
	tl_config.loadToWorkArea(url);
}
var ids="";
//获取checkbox选中
function getCheckedIds() {
	// values are array
	ids = gridObj.getCheckedValues('id').toString();
	if(ids===''){
		easyDialog.open({
			container:{
				header : '请选择',
				content:'请选择要删除的系统!',
				yesFn:true
			},
			autoClose : 2000
		});
	}else{
		easyDialog.open({
			container:{
				header:'提示框',
				content:'确定删除选中的系统吗?',
				yesFn:butchDel,
				noFn:true
			} 
		});
	}
}
//批量删除
function butchDel(){
	$.ajax({
		url : server_url+'/rest/sysInfoDel.do?token='+token,
		type : 'post',
		dataType : 'json',
		data : {
			ids : ids
		},
		success : function(data) {
			if (data.retCode == "0000") {
				var url="sysInfoList.do?ran="+Math.random();
				tl_config.loadToWorkArea(url);
			}else if (data.retCode == "0003") {
				easyDialog.open({
					container:{
						content:data.retMsg
					},
					autoClose : 2000
				});
			}else
				easyDialog.open({container:{content:'删除失败!'},autoClose : 2000});
		}
	});
	
}
